#pragma onec
#include <mysql/mysql.h>
#include "common.h"
#include "config.h"
#include <mutex>

class CDBManage
{
public:
    CDBManage();
    ~CDBManage();
public:
    bool InitDB();
    bool MysqlQuery(const std::string sql);
public:
    //获取目前数据库中所有的用户
    bool GetAllUser(std::unordered_map<int, std::vector<std::string>>& result);
    //查询当前号码是否被注册过
    bool CheckTel(std::string telnum);
    //注册用户
    bool RegisterUser(std::string& nickname, std::string& telnum, 
                     std::string& passwd, int pre_id);
    //返回好友列表
    bool ReturnFriend(int user_id, std::vector<int>& friend_id);
    //更新好友表
    bool RenewFriendInfo(int user_id, int friend_id);
private:
    MYSQL* my_;
};
